<%@page import="servlet.ApprovalTable2"%>
<%@page import="servlet.ApprovalTable1"%>
<%@page import="servlet.AppttypeTable"%>
<%@page import="Logic.Authorizer"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<!-- Declare the first header -->
<jsp:include page="t_header.jsp" />

<script type="text/javascript">
$(document).ready(function(){
	$(".appointmentapprovedlist").change(function(){
		
		var value = this.value;
		
		if (value == "all"){
			$(".approvedbody tr").show();
		}
		
		else{
		$(".approvedbody tr").show();
		$(".approvedbody tr").not("." +value).hide();
		}
	});
	$(apptDescriptionPanel).click(function()
	{
		$(apptDescriptionPanel).hide();
	});
});

function getResponsiblity(){
	var value = document.getElementById("getResponsiblity");
	alert(value.value);
}

function setPopup(appointmentID, event){
		
	//MyWindow=window.open('appttype_responsibilities.jsp?id='+ appointmentID,'MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=250');
	$(apptDescriptionPanel).load('appttype_responsibilities.jsp?id='+ appointmentID);
	$(apptDescriptionPanel).show();
	//var posy = event.clientY + 5;
	//var posx = event.clientX + 20;
	
}
	

	window.onload = function() {
		<%
		if (request.getParameter("print") != null) {
		if (request.getParameter("print").equals("true")) {
			for (int i = 0; i < Integer.parseInt(request.getAttribute("row").toString());i++){
				String md5 = request.getAttribute("md5" + i).toString();
		%>
		window.open("ApptPrint?md5=<%= md5%>", '_blank');
		<%
			}
			}
			}
		%>//add javascript to allow select all checkbox for all pending appointment**
	};
	$(document).on('change','input[name="checkall"]',function() {
		if($('input[name="check"]').is(':checked'))
			{
				$('input[name="check"]').attr('checked',false);
			}
		else{
		$('input[name="check"]').prop("checked",this.checked);
		}
		
		
	});
	

</script>
<%
	if (session.getAttribute("name") == null) {
		response.sendRedirect("login.jsp");
	} else {
		if (Authorizer.checkRole("3", session.getAttribute("role")
				.toString())  || (Authorizer.checkRole("2", session.getAttribute("role")
						.toString()))) {
			
		}
		else
		{
			response.sendRedirect("nopermission.jsp");
						
		}
	}
%>


<jsp:include page="header.html" />


<!-- Declare sidebar -->
<jsp:include page="t_sidebarappointment.jsp" />

<!-- Main Content -->
<section id="main" class="column">

	<!-- Message -->
	<%
		if (request.getParameter("error") != null) {
			if (request.getParameter("error").equals("1")) {
				out.print("<h4 class='alert_error'>No appointment selected.</h4>");
			} else if (request.getParameter("error").equals("2")) {
				if (request.getParameter("action").equals("approved")) {
					out.print("<h4 class='alert_success'>Appointment approved.</h4>");
				} else if (request.getParameter("action")
						.equals("rejected")) {
					out.print("<h4 class='alert_success'>Appointment removed.</h4>");
				} else {
					out.print("<h4 class='alert_success'>Appointment delegated.</h4>");
				}

			}

		}
	%>
	
	
	<article class="module width_full">
		<header>
			<h3>View Appointment</h3>
		</header>
		
		
		<form action="StaffAppChangeStatus" method="POST">
			<input type="submit" name="action" value="Approve" /><input
				type="submit" name="action" value="Approve & Print" /><input
				type="submit" name="action" value="Remove" />   <!-- To be implemented -->
		<div id="apptDescriptionPanel" style="position:absolute;top:100px;left:100px;"></div>
			<table class="tablesorter" cellspacing="0">
				<thead>
					<tr>
						<th><input type="checkbox" name="checkall" value="checkall"/></th>
						<th>Name</th>
						<th>Appointment</th>
					    <th>Diploma</th>
						<th>Year</th>
						<th>Description</th>
						<th>Effective Date</th>
						<!-- <th>Action</th>  -->
					</tr>
				</thead>
				<tbody>
					<%
					//added diploma and year , add checkbox **
						//if (session.getAttribute("role").equals("3")) {
						//	ApprovalTable1 rt = new ApprovalTable1(out);
						//	rt.doGet(request, response);
						//} else {
						ApprovalTable2 rt2 = new ApprovalTable2(out);
						rt2.doGet(request, response);
						//}
					%>
				</tbody>
			</table>
		</form>


	
	</article>

	<!-- end of content manager article -->
	<div class="spacer"></div>
</section>

<!-- Declare closing tags -->
<jsp:include page="t_footer.jsp" />